<?php
class Core_Authentication_Business_Resourceprivilege extends Core_Authentication_Business_Abstract {
	private $_privilegeid;
	private $_resourceid;
	private $_ruleid;
	private $_allow;
	private $_created;
	private $_updated;
	
	public function getPrivilegeId() {return $this->_privilegeid;}
	public function getPrivilege() {return Core_Data_Mappers_Privilege::getById($this->_privilegeid);}
	public function setPrivilegeId($value) {$this->_privilegeid = $value;}
	
	public function getResourceId() {return $this->_resourceid;}
	public function getResource() {return Core_Data_Mappers_Resource::getById($this->_resourceid);}
	public function setResourceId($value) {$this->_resourceid=$value;}
	
	public function getRuleId() { return $this->_ruleid;}
	public function getRule() { return Core_Data_Mappers_Rule::getById($this->_ruleid);}
	public function setRuleId($value) {$this->_ruleid=$value;}
	
	public function getAllow() {return $this->_allow;}
	public function setAllow($value) {$this->_allow=$value;}
	
	public function getCreated() {return $this->_created;}
	public function setCreated($value) {$this->_created=$value;}
	
	public function getUpdated() {return $this->_updated;}
	public function setUpdated($value) {$this->_updated=$value;}
	
	public static function getAllAcl(){
		$map = new Core_Data_Mappers_Resourceprivilege();
		$collection = $map->fetchAll(array("isallow=1"),100);
		return $collection;
	}
	public static function getAcls(){
		$map = new Core_Data_Mappers_Resourceprivilege();
		$collection = $map->fetchAll(array(),1000);
		return $collection;
	}
	public static function getAclByResourceId($id) {
		$map = new Core_Data_Mappers_Resourceprivilege();
		$collection = $map->fetchAll(array("resourceid = ?"=>$id),null);
		return $collection;
	}
	public static function getAclByResourceIdRuleId($resourceid,$ruleid) {
		$map = new Core_Data_Mappers_Resourceprivilege();
		$collection = $map->fetchAll(array("resourceid = ?"=>$resourceid,"ruleid = ?"=>$ruleid),1000);
		return $collection;
	}
}